<?php

namespace App\Http\Requests\User;

use App\Http\Requests\BaseRequest;
use App\Http\Requests\SceneValidator;

class PermissionRequest extends BaseRequest
{
    use SceneValidator;
    /**
     * 这个地方记得为 true, 默认为 false 会返回 403 未授权提示
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * 验证规则
     * sometimes 存在时则验证
     * @return string[]
     */
    public function rules(): array
    {
        $rule = [
            'dept_name'             => 'required',
            'parent_id'              => 'required',
            'dept_id'                   => 'required',
        ];
        return $rule;
    }

    /**
     * Notes:验证不通过提示
     * User: 'jiajia'
     * Date: 2025/10/17
     * Time: 10:18
     * @return string[]
     */
    public function messages(): array
    {
        return [
            'dept_name.required'        => '部门名称必填',
            'parent_id.required'        => '上级部门不能为空',
            'dept_id.required'          => '主键dept_id不能为空',
        ];
    }

    /**
     * Notes:
     * User: 'jiajia'
     * Date: 2025/10/17
     * Time: 10:18
     * @return \string[][]
     */
    public function scene(): array
    {
        return [
            'add'              => ['dept_name','parent_id'],
            'update'           => ['dept_id'],
            'getRow'           => ['dept_id'],
            'delete'           => ['dept_id',],
            'list'             => [],
        ];
    }
}
